/**
 * Copyright (c) 2009 Collaborative Development Group, C.S. Dept., University of Bari
 *
 * All rights reserved. This program and the accompanying materials are made available under
 * the terms of the Eclipse Public License v1.0  which accompanies this distribution, and is 
 * available at http://www.eclipse.org/legal/epl-v10.html
 */
package it.uniba.di.cdg.penelope.ui;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

/**
 * Base support for presentation models: its adds Java Beans' change support.
 */
@SuppressWarnings( "serial" ) // For derived classes
public abstract class AbstractPresentationModel implements IPresentationModel {

	private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport( this );

	public void addPropertyChangeListener( PropertyChangeListener listener ) {
		propertyChangeSupport.addPropertyChangeListener( listener );
	}

	public void addPropertyChangeListener( String propertyName, PropertyChangeListener listener ) {
		propertyChangeSupport.addPropertyChangeListener( propertyName, listener );
	}

	public void removePropertyChangeListener( PropertyChangeListener listener ) {
		propertyChangeSupport.removePropertyChangeListener( listener );
	}

	/**
	 * Notify property change.
	 * @param propertyName
	 * @param oldValue
	 * @param newValue
	 */
	protected void firePropertyChange( String propertyName, Object oldValue, Object newValue ) {
		propertyChangeSupport.firePropertyChange( propertyName, oldValue, newValue );
	}
}
